---
id: "get-index-decorator"
keywords: ["get", "index", "decorator"]
name: "@get_index"
summary: "This is the `@get_index` decorator."
category: "decorators"
---

The `@get_index` decorator is used to access a dynamic property on an object,
or an index of an array.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type t

@new external create: unit => t = "Object"
@set_index external set: (t, string, int) => unit = ""
@get_index external get: (t, string) => int = ""

let o = create()
o->set("x", 1)
o->set("y", 3)
o->set("z", 5)

let value = o->get("y")
```

```js
var o = new Object();

o["x"] = 1;
o["y"] = 3;
o["z"] = 5;

var value = o["y"];
```

</CodeTab>

### References

- [Bind Using Special Getter and Setter Attributes](../docs/manual/bind-to-js-object.mdx#bind-using-special-getter-and-setter-attributes)
